package com.springboot.dao;

import com.springboot.model.User;
import org.apache.ibatis.annotations.*;

/**
 * UserMapper
 * 整合MyBatis
 * @author jlicc
 * @create 2017-03-15-17:14
 **/
@Mapper
public interface UserMapper {

    @Select("SELECT * FROM USER WHERE NAME = #{name}")
    User findByName(@Param("name") String name);

    @Insert("INSERT INTO USER(ID, NAME, AGE) VALUES(#{id}, #{name}, #{age})")
    int insert(@Param("id") Long id, @Param("name") String name, @Param("age") Integer age);

    @Delete("DELETE FROM USER")
    void deleteAll();

    @Update("UPDATE user SET age=#{age}, name=#{name} WHERE id=#{id}")
    void updateById(User user);

    @Delete("DELETE FROM user WHERE id =#{id}")
    void deleteById(Long id);
}
